package com.yqg.manage.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.yqg.manage.controller.dto.IdentificationNumberDTO;
import com.yqg.manage.controller.dto.UsernameDto;
import com.yqg.manage.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author suzhuang
 * @since 2023-07-05
 */
public interface UserMapper extends MPJBaseMapper<User> {

    @Select("select * from user where is_delete = 0")
    List<User> selectAllUser();

    //重置密码————重置为默认密码123456
    @Update("update user set password = #{original_password},update_time = #{date} where id = #{id} and is_delete = 0")
    int resetPwd(@Param("id") int id, @Param("original_password") String password, @Param("date") Date date);

    @Select("select account,username from user where is_delete = 0")
    List<UsernameDto> selectAllName();

    List<IdentificationNumberDTO> allIdentificationNumber();


    User getUserById(Integer id);


    /**
     * 分页查询
     */
    List<User> getPageList(@Param("pageNum") Long pageNum, @Param("pageSize") Long pageSize,
                           @Param("unitId") Long unitId, @Param("userName") String userName,
                           @Param("userId") Long userId, @Param("roleLevel") Long roleLevel);

    Integer getPageListCount(@Param("unitId") Long unitId, @Param("userName") String userName,
                             @Param("userId") Long userId, @Param("roleLevel") Long roleLevel);

    List<User> deputyDirectorFindPage(@Param("pageNum") Long pageNum, @Param("pageSize") Long pageSize,
                                      @Param("unitId") Long unitId, @Param("userName") String userName,
                                      @Param("userId") Long userId, @Param("roleLevel") Long roleLevel);

    Integer deputyDirectorFindPageCount(@Param("unitId") Long unitId, @Param("userName") String userName,
                                        @Param("userId") Long userId, @Param("roleLevel") Long roleLevel);
}
